package com.imooc.o2o.util;

import com.google.code.kaptcha.Constants;

import javax.servlet.http.HttpServletRequest;
import java.util.Locale;


/**
 * @author yangshucheng
 * @create 2021-04-14 19:07
 */
public class CodeUtil {
    public static boolean checkVerifyCode(HttpServletRequest request){
        String verifyCodeExpected = (String) request.getSession().getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
        String verifyCodeActual = HttpServletRequestUtil.getString(request,"verifyCodeActual");
        if (!verifyCodeActual.equalsIgnoreCase(verifyCodeExpected) || verifyCodeActual == null){
            return false;
        }
        return true;
    }
}
